#include <bits/stdc++.h>
#define int long long
#define ps putchar(' ')
#define pe putchar('\n')
using namespace std;
inline int read()
{
    int ans = 0, f = 0;
    char c = getchar();
    while (!isdigit(c))
        f |= c == '-', c = getchar();
    while (isdigit(c))
        ans = (ans << 3) + (ans << 1) + c - 48, c = getchar();
    return f ? -ans : ans;
}
void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(48 + x % 10);
}
const int N = 1e6 + 5;
int n, k;
inline void SPECIAL_EVENT()
{
    vector<int> v;
    for (int i = 1; i <= n; ++i)
        v.push_back(i);
    auto check = [&]()
    {
        for (int i = 0, sum = 0; i < n - 1; ++i)
            if ((sum += v[i]) <= v[i + 1])
                return 0;
        return 1;
    };
    vector<vector<int>> ans;
    do
        if (check())
            ans.push_back(v);
    while (next_permutation(v.begin(), v.end()));
    sort(ans.begin(), ans.end());
    for (int i : ans[k - 1])
        write(i), ps;
}
signed main()
{
    freopen("permutation.in", "r", stdin);
    freopen("permutation.out", "w", stdout);
    n = read(), k = read();
    if (n <= 8)
    {
        SPECIAL_EVENT();
        return 0;
    }
    vector<int> v;
    v.push_back(3);
    for (int i = 1; i <= n; ++i)
        if (i != 3)
            v.push_back(i);
    if (k != 1)
        swap(v[n - 1], v[n - 2]);
    for (int i : v)
        write(i), ps;
    return 0;
}